import request from "@/router/axios";

/**
 * 文件流返回
 * @param url 接口地址
 */
export const exportBlob = (url) => {
  return request({
    url: url,
    method: 'get',
    responseType: 'blob'
  })
}

/**
 * 获取属性列表
 * @param params 请求参数
 */
export const getProperties = (params) => {
  return request({
    url: "/api/manager-api/mx-attribute/queryAttribute",
    method: 'get',
    params
  })
}

/**
 * 获取属性列表
 * @param params 请求参数
 */
export const getPropertiesList = (params) => {
  return request({
    url: "/api/manager-api/mx-attribute/page",
    method: 'get',
    params
  })
}

/**
 * 新增属性列表
 * @param data 请求参数
 */
export const addProperties = (data) => {
  return request({
    url: "/api/manager-api/mx-attribute/insert",
    method: 'post',
    data
  })
}


/**
 * 获取枚举分类
 */
export const getEnumType = () => {
  return request({
    url: "/api/manager-api/mx-code-type/codeTypeClassifyList",
    method: 'get'
  })
}

/**
 * 获取枚举分类
 */
export const getDic = (nameEn) => {
  return request({
    url: "/api/manager-api/mx-code-type/listCodeByTypeName",
    method: 'get',
    params: {
      name: nameEn
    }
  })
}


/**
 *@param params 某个实体的继承接口
 * params treePath => params + oid
 *
 * type EM 实体模型
 * type ER 关系实体
 * */
export const getExtendsList = (params, type = "EM") => {
  return request({
    url: type === "EM" ? '/api/manager-api/mx-interface/getExtendsInterface' : '/api/manager-api/mx-reference/getExtendsList',
    method: 'get',
    params: params
  })
}

/**
 *@param params 某个实体的继承属性
 * typeIds
 * */
export const getAttributesByTypeId = (params) => {
  return request({
    url: '/api/manager-api/mx-attribute/getAttrbutesByTypeId',
    method: 'get',
    params: params
  })
}

/**
 *@param params 获取 规则列表
 * */
export const getRuleList = (params) => {
  return request({
    url: '/api/manager-api/mx-interface-setting/getInterfaceSetting',
    method: 'get',
    params: params
  })
}

/**
 *@param params 获取 单位组
 * */
export const getUnitGroup = (params) => {
  return request({
    url: '/api/manager-api/mx-dimension-group/list',
    method: 'get',
    params: params
  })
}

/**
 *@param params 获取 单位 根据单位组oid查询
 * */
export const getUnit = (params) => {
  return request({
    url: '/api/manager-api/mx-dimension/queryDimensionByGroupId',
    method: 'get',
    params: params
  })
}

/**
 *@param params（oid） 获取 单位 根据单位组oid查询
 * */
export const getListByInterfaceIds = (params) => {
  return request({
    url: '/api/manager-api/mx-operation/getListByInterfaceIds',
    method: 'get',
    params: params
  })
}

/**
 *@param params（oid） 获取 单位 根据单位组oid查询
 * */
export const getByUrl = (params) => {
  return request({
    url: '/api/user-api/client//mx-application/get-by-url',
    method: 'get',
    params: params
  })
}

// 上传图片
export const upload = (formData) => {
  return request({
      headers: {
          "Content-Type": "multipart/form-data"
        },
      url: '/api/file-api/mx-file/upload',
      method: 'post',
      data:formData
    
  })
}

// 上传图片
export const uploadImg = (formData) => {
  return request({
      headers: {
          "Content-Type": "multipart/form-data"
        },
      url: '/api/file-api/mx-file/uploadpicture',
      method: 'post',
      data:formData
    
  })
}

export const getUserList = () => {
  return request({
    url: '/api/user-api/mx-user/list',
    method: 'get',
    params: {}
  })
}